package cn.qzuie.smart.module.dorm.dal.mysql.buildings;

import java.util.*;

import cn.qzuie.smart.framework.common.pojo.PageResult;
import cn.qzuie.smart.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.qzuie.smart.framework.mybatis.core.mapper.BaseMapperX;
import cn.qzuie.smart.module.dorm.dal.dataobject.buildings.BuildingsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.qzuie.smart.module.dorm.controller.admin.buildings.vo.*;

/**
 * 栋 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BuildingsMapper extends BaseMapperX<BuildingsDO> {

    default PageResult<BuildingsDO> selectPage(BuildingsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BuildingsDO>()
                .likeIfPresent(BuildingsDO::getBuildingName, reqVO.getBuildingName())
                .likeIfPresent(BuildingsDO::getNickName, reqVO.getNickName())
                .eqIfPresent(BuildingsDO::getCampus, reqVO.getCampus())
                .eqIfPresent(BuildingsDO::getTotalFloors, reqVO.getTotalFloors())
                .eqIfPresent(BuildingsDO::getTotalRooms, reqVO.getTotalRooms())
                .eqIfPresent(BuildingsDO::getCharger, reqVO.getCharger())
                .betweenIfPresent(BuildingsDO::getBuildDate, reqVO.getBuildDate())
                .betweenIfPresent(BuildingsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BuildingsDO::getId));
    }

}